from django.db import models

# Create your models here.


class User(models.Model):
    name = models.CharField(unique=True, max_length=10)
    tel = models.CharField(max_length=11)
    gender = models.CharField(max_length=1, blank=True, null=True)
    birthday = models.CharField(max_length=10, blank=True, null=True)
    nick_name = models.CharField(max_length=20)
    credit_score = models.IntegerField(blank=True, null=True)
    password = models.CharField(max_length=255)
    alipay = models.CharField(max_length=20, blank=True, null=True)
    user_type = models.CharField(max_length=2)
    photo = models.CharField(max_length=255)
    user_dentity = models.CharField(max_length=18)
    create_time = models.DateTimeField(blank=True, null=True,auto_now_add=True)
    update_time = models.DateTimeField(blank=True, null=True,auto_now=True)

    class Meta:
        managed = False
        db_table = 'user'


class ShoppingTrolley(models.Model):
    mid = models.ForeignKey('items.Commodity', models.CASCADE, db_column='mid')
    uid = models.ForeignKey(User, models.CASCADE, db_column='uid')
    create_time = models.DateTimeField(blank=True, null=True,auto_now_add=True)
    update_time = models.DateTimeField(blank=True, null=True,auto_now=True)

    class Meta:
        managed = False
        db_table = 'shopping_trolley'

class Address(models.Model):
    user = models.ForeignKey(User, models.CASCADE)
    name = models.CharField(max_length=30)
    tel = models.CharField(max_length=11)
    location = models.CharField(max_length=50)
    is_default = models.CharField(max_length=1)
    location_desc = models.CharField(max_length=255)
    create_time = models.DateTimeField(blank=True, null=True,auto_now_add=True)
    update_time = models.DateTimeField(blank=True, null=True,auto_now=True)

    class Meta:
        managed = False
        db_table = 'address'
